package com.example.androidstart;


import android.app.Activity;
import android.os.Bundle;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.androidstart.homepage.HomePageAdapter;
import com.example.androidstart.homepage.ItemInfo;
import com.example.androidstart.homepage.bean.GoodsInfoBean;
import com.example.androidstart.homepage.bean.IconInfoBean;
import com.example.androidstart.homepage.item.GoodsItemInfo;
import com.example.androidstart.homepage.item.IconItemInfo;
import com.example.androidstart.homepage.item.ImageItemInfo;

import java.util.ArrayList;
import java.util.List;

public class SimpleHomePageActivity extends Activity {

    private List<ItemInfo> mItemInfos = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple_home_page);

        ImageItemInfo imageItemInfo = new ImageItemInfo(R.drawable.home_img);

        IconInfoBean iconInfoBean = new IconInfoBean();
        iconInfoBean.setIconImgRes(R.drawable.boy);
        iconInfoBean.setmIconName("icon显示");
        IconItemInfo iconItemInfo = new IconItemInfo(iconInfoBean);

        GoodsInfoBean goodsInfoBean = new GoodsInfoBean();
        goodsInfoBean.setmGoodsName("测试手机");
        goodsInfoBean.setmGoodsPrice("+∞$");
        goodsInfoBean.setmGoodsRes(R.drawable.phone);
        GoodsItemInfo goodsItemInfo = new GoodsItemInfo(goodsInfoBean);


        mItemInfos.add(imageItemInfo);
        mItemInfos.add(iconItemInfo);

        for (int i = 0; i < 10; i++) {
            mItemInfos.add(goodsItemInfo);
        }
        RecyclerView recyclerView = findViewById(R.id.recyclerView);
        HomePageAdapter homePageAdapter = new HomePageAdapter(mItemInfos);
        recyclerView.setAdapter(homePageAdapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));

    }
}